from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import init

class Index(webapp.RequestHandler):
    def get(self):
        self.response.out.write('<a href="/Register">login</a>')
        
class Register(webapp.RequestHandler):
    def get(self):
        self.response.out.write(init.render('register.html'))
    def post(self):
        import UserModel
        user = UserModel.UserModel()
        user.email = self.request.get('email')
        user.password = self.request.get('password')
        user.put()

class Users(webapp.RequestHandler):
    def get(self):
        import UserModel
        users = UserModel.UserModel().all()
        for user in users:
            self.response.out.write(user.email)
        
application = webapp.WSGIApplication(
                                    [('/', Index),
                                     ('/Register', Register),
                                     ('/Users', Users)],
                                    debug = True)

if __name__ == '__main__':
    run_wsgi_app(application)
